﻿using System;
using System.Collections.Generic;


namespace DailyFx.AI
{
	public class SimpleMadiator : IMediator 
	{
		/// <summary>
		///		Contains direct mappings from task to export .
		/// </summary>
		private IDictionary<String, IExpert> _mappings = new Dictionary<String, IExpert>();


		public void createMapping ( ITask task, IExpert export ) 
		{
			_mappings.Add (task.Label, export);
		}

		public void setMappings ( IDictionary<String, IExpert> mappings )
		{
			this._mappings = mappings;
		}



		public IReadOnlyCollection<IExpert> mediate ( ITask task )
		{
			IExpert expert = null ;
			bool ok = this._mappings.TryGetValue( task.Label, out expert ) ;
			
			if ( !ok ) 
			{
				return null ;
			}

			List<IExpert> experts = new List<IExpert>(); 
				experts.Add ( expert );
			
			return experts;
		}
}

}
